package com.ymatou.iapi.optrade.parameter.enums;

import java.util.HashMap;
import java.util.Map;

public enum CancelOrderTypeEnum {

	//买家取消
	BUYER_CANCEL_ORDER(1),
	//卖家取消
	SELLER_CANCEL_ORDER(2),
	//客服取消
	CUSTOMER_CANCEL_ORDER(3),
	//系统取消
	SYSTEM_CANCEL_ORDER(4),
	//风控取
	RISKCONTROL_CANCEL_ORDER(5),
	//砍价团取消
	BARGAINGROUP_CANCEL_ORDER(6),
	//超过每年20000限额
	EXCEEDLIMIT_CANCEL_ORDER(7),
	//预售订单-买家违约
    BOOKINGORDER_USER_VIOLATION(8),
    //预售订单-买手违约
    BOOKINGORDER_SELLER_VIOLATION(9),
    //预售订单二次确认后长时间未支付全款
    BOOKINGORDER_UNPAID_FULLAMOUNT(10);

	int code;

	private static final Map<Integer, CancelOrderTypeEnum> maps = new HashMap<>();

	static {
		for (CancelOrderTypeEnum cancelOrderTypeEnum : CancelOrderTypeEnum
				.values()) {
			maps.put(cancelOrderTypeEnum.getCode(), cancelOrderTypeEnum);
		}
	}

	CancelOrderTypeEnum(int code) {
		this.code = code;
	}

	public int getCode() {
		return code;
	}

	public static CancelOrderTypeEnum newInstance(String code) {
		try {
			int temp = Integer.valueOf(code);
			return maps.get(temp);
		} catch (NumberFormatException e) {
			return CancelOrderTypeEnum.valueOf(code);
		}
	}
}
